package cn.ultrarisk.scadmin.manager.biz.solr.valid;

import cn.ultrarisk.scadmin.manager.biz.zookeeper.operator.ZookeeperOperator;
import cn.ultrarisk.scadmin.manager.exception.BizCheckedException;
import cn.ultrarisk.scadmin.manager.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ZKBackupValidator
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/6/3
 * @since V1.0
 */
@Component
public class ZKBackupValidator {
    @Autowired
    private ZookeeperOperator zookeeperOperator;

    public void validPath(String path) {
        if (StringUtil.isEmpty(path)) {
            throw new BizCheckedException("the path can't be empty");
        }
        if (zookeeperOperator.getStat(path) == null) {
            throw new BizCheckedException("the path is't exist zookeeper server");
        }
    }
}
